package com.egene.tw.activity.product;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.egene.tw.R;
import com.egene.tw.base.RecycleBaseAdapter;
import com.egene.tw.model.Category;

/**
 * Created by WZX on 2015/8/16.
 */
public class CategoryRecycleAdapter extends RecycleBaseAdapter {
    public CategoryRecycleAdapter() {
    }

    public CategoryRecycleAdapter(View headerView) {
        mHeaderView = headerView;
    }

    @Override
    public View onCreateItemView(ViewGroup parent, int viewType) {
        return getLayoutInflater(parent.getContext()).inflate(R.layout.item_category, null);
    }

    @Override
    protected RecycleBaseAdapter.ViewHolder onCreateItemViewHolder(View view, int viewType) {
        return new ViewHolder(viewType, view);
    }

    @Override
    protected void onBindItemViewHolder(RecycleBaseAdapter.ViewHolder vh, int position) {
        super.onBindItemViewHolder(vh, position);
        CategoryRecycleAdapter.ViewHolder holder = (CategoryRecycleAdapter.ViewHolder) vh;
        Category category = (Category) _data.get(position);
        holder.tvTitle.setText(position + 1 + "  "+category.getTitle());

    }

    public static class ViewHolder extends RecycleBaseAdapter.ViewHolder {
        public TextView tvTitle;

        public ViewHolder(int viewType, View view) {
            super(viewType, view);
            tvTitle = (TextView) view.findViewById(R.id.tvTitle);
        }
    }
}
